﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using BLL.Validation;
using Entities;
using Entities.IRepository;

namespace BLL
{
    public class QLHoaDon : IValidator<HoaDon>
    {
        private readonly IGeneralRepository<HoaDon> _repository;

        public QLHoaDon(IGeneralRepository<HoaDon> itr)
        {
            _repository = itr;
        }

        public ValidationResult Validate(HoaDon hd)
        {
            var vResult = new ValidationResult();
            return vResult;
        }

        /// <summary>
        /// thêm hóa đơn
        /// </summary>
        /// <param name="hd"></param>
        /// <returns></returns>
        public ActionResult Insert(HoaDon hd)
        {
            var aResult = new ActionResult();
            try
            {
                if (!_repository.Insert(hd))
                    aResult.Exceptions.Add(new Exception("Thêm mới hóa đơn không thành công"));
            }
            catch (Exception ex)
            {
                aResult.Exceptions.Add(ex);
            }
            return aResult;
        }
    }
}
